package org.scohen.juploadr.ui;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.SWT;

public class PopupData {
    public static final PopupData SEPARATOR = new PopupData(
            PopupHandler.SEPARATOR, true);
    private String text;
    private Object value;
    private int type = SWT.PUSH;
    private boolean checked;
    private List<PopupData> children = null;
    private boolean enabled;

    public PopupData(String nm, boolean enabled) {
        this.text = nm;
        this.enabled = enabled;
    }

    public PopupData(String nm, Object val, boolean enabled) {
        this(nm, enabled);
        this.value = val;
    }

    /**
     * @return Returns the name.
     */
    public String getText() {
        return text;
    }

    /**
     * @param name
     *            The name to set.
     */
    public void setText(String name) {
        this.text = name;
    }

    /**
     * @return Returns the value.
     */
    public Object getValue() {
        return value;
    }

    /**
     * @param value
     *            The value to set.
     */
    public void setValue(Object value) {
        this.value = value;
    }

    /**
     * @return Returns the checked.
     */
    public boolean isChecked() {
        return checked;
    }

    /**
     * @param checked
     *            The checked to set.
     */
    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    /**
     * @return Returns the type.
     */
    public int getType() {
        return type;
    }

    /**
     * @param type
     *            The type to set.
     */
    public void setType(int type) {
        this.type = type;
    }

    public List<PopupData> getChildren() {
        return children;
    }

    public void addChild(PopupData child) {
        if (children == null) {
            children = new ArrayList<PopupData>();
        }
        children.add(child);
    }

    public boolean hasChildren() {
        return children != null && children.size() > 0;
    }

    /**
     * @return Returns the enabled.
     */
    public boolean isEnabled() {
        return enabled;
    }

    /**
     * @param enabled
     *            The enabled to set.
     */
    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }
}
